package com.wei.duowan.bbs.utils;


import android.content.Context;
import android.support.annotation.NonNull;

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.cache.DiskLruCacheFactory;
import com.bumptech.glide.module.AppGlideModule;

import java.io.File;

/**
 * 作者：赵若位
 * 时间：2019/8/21 21:48
 * 联系方式：1070138445
 * 功能：
 */
@GlideModule
public class GlideCache extends AppGlideModule
{
    private static final long CACHE_MAX_SIZE = 100 * 1024 * 1024;

    @Override
    public void applyOptions(@NonNull Context context, @NonNull GlideBuilder builder)
    {
        super.applyOptions(context, builder);
        File cache = CacheFileUtils.getInstance().getCacheFile();
        if (!cache.exists())
        {
            cache.mkdirs();
        }
        builder.setDiskCache(new DiskLruCacheFactory(cache.getPath(), CACHE_MAX_SIZE));
    }
}
